const Router = require('koa-router')

const userRouter = new Router({prefix:'/users'})
const {
  verifyUser
} = require('../middleware/userMiddleware')
const {
  createUser,
  getUserList,
  getUserById,
  updateUserById,
  removeUserById,
  changeUserRole
} = require('../controller/userController')
const {
  verifyAuth
} = require('../middleware/authMiddleware')
//注册用户
userRouter.post('/', verifyUser, createUser)
//获取用户列表
userRouter.post('/list', verifyAuth, getUserList)
//获取id用户
userRouter.get('/:id', verifyAuth, getUserById)
//编辑用户
userRouter.patch('/:id', verifyAuth, updateUserById)
//删除用户
userRouter.delete('/:id', verifyAuth, removeUserById)
//分配用户角色
userRouter.put('/:id/role',verifyAuth,changeUserRole)


module.exports = userRouter